Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batches: skip empty log output #923

Merged
merged 8 commits into from
Jan 13, 2023
Merged

Conversation

BolajiOlajide
Copy link
Contributor

Test plan

I added a unit test for this.

@BolajiOlajide BolajiOlajide self-assigned this Jan 12, 2023
@BolajiOlajide BolajiOlajide requested a review from a team January 12, 2023 23:23
@@ -119,6 +119,14 @@ type prefixedWriter struct {
func (w *prefixedWriter) Write(p []byte) (int, error) {
Copy link
Member

@eseliger eseliger Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the source of p and I think we will only ever stream 1 line at a time, either with the newline at the end, or not if the stream has ended and there is no newline (for example echo -n).
So that makes me think that we shouldn't even split the p in here at all - and would as a side-effect get that for free, while retaining actual empty log lines. How does that feel for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Yeah true - that's better. I can just remove the loop then. It makes sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just re-validate that - but from reading code it seems like our scanner on the other end of this stream would write in line-chunks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just tested it, and it works. For both SSBC and local executions - the log output is consistent now.
Pushed a refactor.

Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

internal/batches/ui/interval_writer.go Outdated Show resolved Hide resolved
internal/batches/ui/interval_writer.go Show resolved Hide resolved
@BolajiOlajide BolajiOlajide merged commit c84c80a into main Jan 13, 2023
@BolajiOlajide BolajiOlajide deleted the bo/fix-duplicate-log-output branch January 13, 2023 13:12
scjohns pushed a commit that referenced this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants